<%@page language="Java" contentType="text/html; UTF-8"
pageEncoding="UTF-8"%>

<%@taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html"%>
<%@taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean"%>
<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.Statement" %>
<%@ page import="java.sql.ResultSet" %>
<%@ page import="ssi.tools.Connector" %>
<%@ page import="ssi.beans.User" %>

<%
	User user=(User)session.getAttribute("user");
	String type=user.getTypeOfUser().toString();
	Connection connection = new Connector().getConnection();
	Statement statement = connection.createStatement();
	ResultSet result=null;
	int numberOfRows=0;
	if(type.equals("ADMIN")){
		result = statement.executeQuery("SELECT name, surname, email, address, type FROM users where email <>'"+user.getEmail()+"'");
		numberOfRows = Connector.getRowCount(result);
	}else if(type.equals("BOSS")){
		result = statement.executeQuery("SELECT name, surname, email, address, type FROM users where email <>'"+user.getEmail()+"' && type<>'ADMIN'");
		numberOfRows = Connector.getRowCount(result);
	}else if(type.equals("WORKER")){
		result = statement.executeQuery("SELECT name, surname, email, address, type FROM users where email <>'"+user.getEmail()+"' && type<>'ADMIN' && type<>'BOSS'");
		numberOfRows = Connector.getRowCount(result);
	}
%>


<h2>Nadaj range:</h2><br>
<html:form action="changeType">
<table>
<tr>
<td><p>U�ytkownik:</td><td><select name="email" id="user">
<%
while(result.next()){%>
<option number="a"><%=result.getString("email")%></option>
<% 
} %>
</select></td>
</tr>
<tr>
<td><p>Ranga:</td><td><select name="type" id="type">
<option number="a">ADMIN</option>
<option number="b">BOSS</option>
<option number="c">WORKER</option>
<option number="d">USER</option>
</select></td>
</tr>
</table>
<br>
<input type="submit" class="submit" value="Nadaj"/><br>
<font color="green"><html:errors property="info" /></font>

	
</html:form>
